package lk.mrt.cse.wihidum.storage;

import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * Created by IntelliJ IDEA.
 * User: Hasini
 * Date: Apr 12, 2010
 * Time: 8:00:03 PM
 * To change this template use File | Settings | File Templates.
 */
public class ClientList
{
    private static final Logger logger = Logger.getLogger (BrokerList.class);
    private static ArrayList<String> clientAddressList=new ArrayList<String>();
    public static void addClientToList(String clientAddress)
    {
        if(isEmpty())
        {
             clientAddressList.add(clientAddress);
             logger.info("Client: "+clientAddress+" was added to list.");
        }
        else
        {
            boolean found = false;
            for(String address: clientAddressList)
            {
                if(address.equals(clientAddress))
                   found = true;
            }
            if(!found)
                clientAddressList.add(clientAddress);            
        }
    }
    public static boolean isEmpty()
    {
            boolean empty=false;
            empty=clientAddressList.isEmpty();            
            return empty;
    }
    public static ArrayList<String> getClientList()
    {
        return clientAddressList;
    }
}
